<?php
class UserMapper{
    private static $_instence;
    private function _construct(){}
    
    public static function instence(){
        if(null ===  UserMapper::$_instence){
            UserMapper::$_instence = new UserMapper();
        }
        return UserMapper::_instence;
    }
    public static function seve(User $user){
    	$query = "INSERT INTO user VALUES(NULL, '"
                    .$user->getLogin()."', '"
                    .$user->getEmail()."', '"
                    .$user->getPassword()."')";
          
            DatabasePDO::Execute($query);
    }
    public static function auth($email, $password){
        $sql = "SELECT id, password FROM users WHERE email = '$email'";
        $customer =  DatabasePDO::GetRow($sql);
        
        if($password == $customer['password']){
        
		    return $customer['id'];
        }else{
        	
            return NULL;
        }
		
        
    }
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
